﻿Namespace UI
    Public Class TemplateMgmt
        Inherits UI.IPage

        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim sb As New StringBuilder()
            sb.AppendLine(GetSubDir("/templates"))
            Response.Write(sb.ToString())
        End Sub

        Public Function GetSubDir(ByVal path As String) As String
            Dim sb As New StringBuilder()
            Dim curDir As New IO.DirectoryInfo(Server.MapPath((path)))

            sb.AppendFormat("<ul><li><a href=""{0}"">{1}</a>", "javascrit:void(0)//" + path, curDir.Name)


            For Each di As IO.DirectoryInfo In curDir.GetDirectories
                sb.AppendLine(GetSubDir(path + "/" + di.Name))
            Next


            sb.AppendLine("</li>")
            For Each fi As IO.FileInfo In curDir.GetFiles
                sb.AppendLine("<li>")
                sb.AppendFormat("<a href=""{0}"">{1}</a>", "javascrit:void(0)//" + path + "/" + fi.Name, fi.Name)
                sb.AppendLine("</li>")
            Next


            sb.AppendLine("</ul>")
            Return sb.ToString
        End Function
    End Class
End Namespace
